<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>用户登录切换的案例（小问题）</title>
</head>
<body>
<div id="app">
  <!--之前的登录方式切换后，input中的值仍然存在，我们不希望这个值在切换登录方式后仍然存在，那么就加上key-->
  <span v-if="isLoginType">
    <label for="userName">用户账号</label>
    <input type="text" id="userName" placeholder="请输入用户账号" key="userName">
  </span>
  <span v-else>
    <label for="email">用户邮箱</label>
    <input type="email" id="email" placeholder="请输入邮箱地址" key="email">
  </span>

  <button @click="isLoginType = !isLoginType">切换登录类型</button>
</div>
<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      isLoginType: true
    }
  });
</script>
</body>
</html>
